package com.chainyoung.component_tmperson.ui.mvp.model;

import com.chainyoung.common.integration.IRepositoryManager;
import com.chainyoung.common.mvp.BaseModel;
import com.chainyoung.common.utils.RxUtils;
import com.chainyoung.component_tmperson.api.PersonService;
import com.chainyoung.component_tmperson.entity.PurseAddr;
import com.chainyoung.component_tmperson.entity.WalletDebit;
import com.chainyoung.component_tmperson.entity.WalletRepayment;
import com.chainyoung.component_tmperson.ui.mvp.contract.WalletAddrContract;
import com.chainyoung.component_tmperson.ui.mvp.contract.WalletApplyDebitContract;

import java.util.List;
import java.util.TreeMap;

import javax.inject.Inject;

import io.reactivex.Flowable;

public class WalletApplyDebitModel extends BaseModel implements WalletApplyDebitContract.Model {

    @Inject
    WalletApplyDebitModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);

    }


    @Override
    public Flowable<List<WalletDebit>> getDebitPeriodsSuccess(TreeMap<String, Object> map) {
        return mRepositoryManager.obtainRetrofitService(PersonService.class)
                .getWalletDebitPeriods(map)
                .compose(RxUtils.<List<WalletDebit>>handleResult());
    }

    @Override
    public Flowable<List<String>> getPurposeList() {
        return mRepositoryManager.obtainRetrofitService(PersonService.class)
                .getPurposeList()
                .compose(RxUtils.<List<String>>handleResult());
    }

    @Override
    public Flowable<String> getDebitCredit(TreeMap<String, Object> map) {
        return mRepositoryManager.obtainRetrofitService(PersonService.class)
                .getDebitCredit(map)
                .compose(RxUtils.<String>handleResult());
    }

    @Override
    public Flowable<List<WalletRepayment>> getRepaymentScheduleList(TreeMap<String, Object> map) {
        return mRepositoryManager.obtainRetrofitService(PersonService.class)
                .getRepaymentSchedules(map)
                .compose(RxUtils.<List<WalletRepayment>>handleResult());
    }

    @Override
    public Flowable<String> applyDebit(TreeMap<String, Object> map) {
        return mRepositoryManager.obtainRetrofitService(PersonService.class)
                .applyDebit(map)
                .compose(RxUtils.<String>handleResult());
    }



}

